<?php

namespace Home\Controller;
use Home\Controller\UserController;
class OrdersController extends UserController {
	public function _initialize() {
		//header("Access-Control-Allow-Origin: *");
		parent::_initialize ();
	}
	// 交易页面显示
	public function index() {
 	     $list = M ( 'Currency' )->order('currency_id asc')->select ();
 	     $price = $this->getPrice();
 	    foreach ($list as $k=>$v){
 	        //最新价
     	    $url="https://api.huobi.pro/market/detail/merged?symbol=".$v['currency_mark']."usdt";
     	    $url1 = "https://api.huobi.pro/market/history/kline?period=1day&size=1&symbol=".$v['currency_mark']."usdt";
			
     	    //$result=file_get_contents($url);
			$result=$this->curl_get($url);
			//dump($url);
			//dump($result);die;
     	    $result1=$this->curl_get($url1);
     	    $list[$k]['price'] =  $result['tick']['close'];
     	    $list[0]['price'] =  $price['price2'];
     	    $list[1]['price'] =  $price['price3'];
     	    $list[2]['price'] =  $price['price4'];
     	    $list[$k]['zhangfu'] = (($result['tick']['close']-$result1['data'][0]['open'])/$result1['data'][0]['open'])*100;
 	    }
 	    $config = $this->getConfig();
 	    $return['vic_price'] = $config['vic_price'];
 	    $return['vic_zhangfu'] = $config['vic_zhangfu'];
 	    $return['list'] = $list;
 	    $return['status'] = 1;
 	    $this->ajaxReturn($return);
	}
}